﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="game_gamemanage.aspx.cs" Inherits="backmanage_gamesystem_game_gamemanage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>添加游戏</title>
    <script type="text/javascript" src="../js/jquery1.6.2.js"></script>
	<script type="text/javascript" src="../external/jquery.bgiframe-2.1.2.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.widget.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.mouse.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.button.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.draggable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.position.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.resizable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.dialog.js"></script> 
	<script type="text/javascript" src="../js/jquery.effects.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ajax.upfile.js"></script>
	<script type="text/javascript" src="../js/jquery.ingrid.js"></script>
	<link rel="Stylesheet" href="../css/ingrid.css" />
    <link rel="stylesheet" href="../css/demos.css" />
    <link rel="stylesheet" href="../css/jquery.ui.all.css" />
    <script type="text/javascript">
     $(function(){
     $("#dialog-form").dialog("destory");
          var name = $( "#name" ),
				    register = $( "#register" ),
				    download=$("#download"),
				    url=$("#url"),
				    company=$("#company"),
				    money=$("#money"),
				    allFields = $( [] ).add( name ).add( register ).add(download).add(url).add(company).add(money),
				    tips = $( ".validateTips" );
                function updateTips(t)
                {
                  tips.text(t)	
                      .addClass("ui-state-highlight");
                  setTimeout(function(){
                      tips.removeClass("ui-state-highlight",1500);
                  },500);
                }
                function checkEmpty(e,n)
                {
                  if(e.val().length>0){
                     return true;}
                  else{
                     e.addClass("ui-state-error");
                     updateTips(n+"不能为空.");
                     return false;
                     }
                }
                function GameAdd()
                {
                  var n=$("#name").val(),c=$("#company").val(),r=$("#register").val(),d=$("#download").val(),u=$("#url").val(),l=$("#adImg").attr("src"),m=$("#money").val(),s=$("#state").find("option:selected").attr("value");
                  var flag;
                  $.ajax({
                        anysc:false,
                        url:'../API/A_Game.aspx',
                        type:"POST",
                        data:{edit:"add",n:n,c:c,r:r,d:d,u:u,l:l,m:m,s:s},
                        dataType:'json',
                        success:function(data)
                        {
                          flag=data.msg;
                        }
                  })
                  
                  if(flag=="true")
                  return true;else return false;
                  
                }
                function GameList()
                {
                  $.ajax({
                      anysc:false,
                      url:'../API/A_Game.aspx',
                      type:'POST',
                      data:{edit:'list'},
                      success:function(msg)
                      {
                        $("#gamelist tbody").replaceWith(msg);
                      }
                  })
                }
                function AppendTable()
                {
                 var n=$("#name").val(),c=$("#company").val(),r=$("#register").val(),d=$("#download").val(),u=$("#url").val(),l=$("#adImg").attr("src"),m=$("#money").val(),s=$("#state").find("option:selected").attr("value");
                 $("#gamelist tbody").append("<tr>"+n+"<td></td><td>"+c+"</td><td><img alt=\""+n+"\" src=\""+l+"\" /></td><td>"+u+"</td><td>"+r+"</td><td>"+d+"</td><td>"+m+"</td><td><a href=\"#\">编辑</a></td></tr>")
                }
        $("#dialog-form").dialog({
                     autoOpen:false,
                     height:480,
                     width:600,
                     modal:true,
                     buttons:{
                               "提交":function(){
                                   var flag=true;
                                   allFields.removeClass("ui-state-error");
                                       
                                   flag=flag && checkEmpty(name,"游戏名称");
                                   flag=flag && checkEmpty(company,"运营公司");
                                   flag=flag && checkEmpty(url,"官方网站");
                                   flag=flag && checkEmpty(register,"注册地址");
                                   flag=flag && checkEmpty(download,"下载地址");
                                   flag=flag && checkEmpty(money,"每小时消耗点数");
                                   if(flag)
                                   {
                                        GameAdd();
                                        GameList();
                                        $(this).dialog("close");
                                        
                                   }
                               },
                               "取消":function(){
                                   $(this).dialog("close");
                               },
                             },
                      close:function(){allFields.val("").removeClass("ui-state-error");
                      },
          });
           function ajaxFileUpload()
               {
                    $.ajaxFileUpload(
                                   {
                                url:'../API/A_Fileupload.aspx?uptype=2',            
                                secureuri:false,
                                fileElementId:'fup',
                                data:{uptype:'2'},
                                dataType: 'json',                                  
                                success: function (data, status)
                                {
                                    if(data.err=="")
                                    {
                                        document.getElementById("adImg").src=data.msg;
                                    }
                                    else
                                    {
                                        alert(data.err);
                                    }
                                },
                                error: function (data, status, e)
                                {
                                    alert("上传失败!");
                                }
                            });
               }
           function SetTable(){
		  $("#cardlist").tableSorter({
		        sortColumn: 'name',			
		        sortClassAsc: 'headerSortUp',		
		        sortClassDesc: 'headerSortDown',	
		        headerClass: 'header',
		  });}
          $("#upload").click(function(){ajaxFileUpload();});
          $("#create-user").button().click(function(){$("#dialog-form").dialog("open");});
          $(document).ready(function(){GameList(); SetTable();});
     })
    </script>
    <style type="text/css">
        body { font-size: 62.5%; }
		label, input { display:block;}
		input.text { margin-bottom:12px; width:95%; padding: .4em; }
		fieldset { padding:0; border:0; margin-top:25px; }
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain { width: 350px; margin: 20px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
		.ui-dialog .ui-state-error { padding: .3em; }
    	.validateTips { border:1px transparent solid; padding: 0.3em; }
		.validateTips input{border:1}
		.text{border:1}
		div#img-size{ width:200px}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    添加游戏信息
    <a id="create-user">添加游戏信息</a>
    <table id="gamelist" name="gamelist" >
      <thead>
        <tr>
          <th>游戏名称</th>
          <th>运营公司</th>
          <th>游戏logo</th>
          <th>官方网站</th>
          <th>注册地址</th>
          <th>下载地址</th>
          <th>每小时点数</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      </tbody>
      <tfoot>
         <tr>
          <td colspan="11">
            一共100页 第一页
          </td>
        </tr>
      </tfoot>
    </table>
    <div id="dialog-form" title="添加游戏信息">
    <p class="validateTips">填写要添加的游戏信息.</p> 
    <fieldset>
    <table style="width:500px">
      <tr>
        <td colspan="4">
           <label for="name">游戏名称</label>
           <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
        </td>
        </tr>
        <tr>
        <td colspan="2">
           <label for="company">运营公司</label>
           <input type="text" name="company" id="company" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        <td colspan="2">
           <label for="url">官方网站</label>
           <input type="text" name="url" id="url" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        
      </tr>
      <tr>
      <td colspan="2">
           <label for="register">注册地址</label>
           <input type="text" name="register" id="register" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        <td colspan="2">
           <label for="download">下载地址</label>
           <input type="text" name="download" id="download" value="" class="text ui-widget-content ui-corner-all" />
        </td>
      </tr>
      <tr>
        <td colspan="2">
           <label for="money">每小时点数</label>
           <input type="text" name="money" id="money" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        <td colspan="2">
           <label for="state">可用状态</label>
           <select id="state">
              <option value="T">可用</option>
              <option value="F">不可用</option>
           </select>
        </td>
        </tr>
        <tr>
        <td colspan="4">
           <label for="logo">游戏logo</label>
           <img src="" alt="" id="adImg" /><br />
           <input id="fup" name="fup" type="file" style="width:100px" /><input type="button" id="upload" value="上传"/>
        </td>
      </tr>
    </table>
    </fieldset>
    </div>
    </div>
    </form>
</body>
</html>
